package com.t235.gc;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

@Data
@ApiModel("gc项目api接口统一返回值对象")
@JsonIgnoreProperties({"hibernateLazyInitializer"," handler"})
public class AjaxResult implements Serializable{
    @ApiModelProperty(dataType = "string", value = "状态码（200表示成功500表示服务器内部错误）", example = "200")
    private String code;
    @ApiModelProperty(dataType = "string", value = "响应消息", example = "成功")
    private String msg;
    @ApiModelProperty(dataType = "object", value = "响应载荷", example = "{}")
    private Object data;
    @ApiModelProperty(dataType = "object", value = "响应载荷", example = "{}")
    private Long count;


    private AjaxResult() {

    }
    private AjaxResult(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    private AjaxResult(String code, String msg, Object data, Long count) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.count = count;
    }

    public static AjaxResult success() {
        return new AjaxResult("200", "success", null);
    }

    public static AjaxResult success(String msg) {
        return new AjaxResult("200", msg, null);
    }

    public static AjaxResult success(Object data, Long count) {
        return new AjaxResult("200", "success", data,count);
    }


    public static AjaxResult success(Object data) {
        return new AjaxResult("200", "success", data);
    }

    public static AjaxResult error() {
        return new AjaxResult("500", "error", null);
    }

    public static AjaxResult error(String msg) {
        return new AjaxResult("500", msg, null);
    }
}
